package com.luoluo.controller;

import com.luoluo.dao.LeaveWordMapper;
import com.luoluo.dao.TouristsLeaveWordMapper;
import com.luoluo.pojo.LeaveWord;
import com.luoluo.pojo.TouristsLeaveWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.*;

/**
 * 其它的，非直接关系的请求都放这里
 */
@Controller
public class GlobalController {

    @Autowired
    LeaveWordMapper leaveWordMapper;
    @Autowired
    TouristsLeaveWordMapper touristsLeaveWordMapper;
    /**
     * 无法识别的任意一级请求都将转发到主页！
     *
     * @return
     */
    @RequestMapping("/*")
    public String index(@RequestParam(value = "part",defaultValue = "10")Integer number, Model model){
        System.out.println("主页");
        //请求到当前的所有的留言数据
        List<LeaveWord> leaveWordList = leaveWordMapper.selectPart(number);
        System.out.println("请求到的数据量："+leaveWordList.size());
        model.addAttribute("leaveWords",leaveWordList);
        return "index";
    }

}
